define(function(require, exports){
	var util = require('util');
	var pubjs = require('pubjs');
	var baseGrid = require('@base/grid');
	var $ = require('jquery');

	// 基础条件表格
	var Base = baseGrid.baseNoDate.extend({
		init : function( config ) {
			config = pubjs.conf( config, {
				"cols" : [
					{ type: 'id', width: 50 },
					{ name : "Conditions", width: 600 ,text : LANG("条件"), align : "left", render: 'renderCondition' }
					,{"type": "op", "render": 'renderOp'}
				],
				"opClick": true,
				'default_sort': false,
				"hasExport" : false,
				"hasAmount" : false,
				"hasTab" : false,
				'hasPager': false,
				'hasSelect': false,
				'hasSearch': false,
				'sub_field': '_id',
				'list': {
					'scroll_type': 'row',
					'scroll_size': 4
				}
			});
			this.Super( "init", arguments );
		},
		renderOp: function() {
			return ['<a data-op="edit" title="'+LANG("编辑")+'">'+LANG("编辑")+'</a>'
				,'<a data-op="del" title="'+LANG("删除")+'">'+LANG("删除")+'</a>'
			].join(' | ')
		},
		renderCondition: function(i, val, data, conf)
		{
			if(data && data.length)
			{
				var div = '<div class="P-CustomDownloadConditionGrid">';
				util.each(data, function(item, i) {
					var content = '';
					if (item.value) {
						content = item.value;
					}
					else if (item.chooseData.length){
						var chooseValues = [];
						item.chooseData.forEach(function(val){
							chooseValues.push(val.value);
						});
						content = chooseValues.join('，');
					}
					var text = `${i === 0 ? '' : '且  '}${item.dimText}  ${item.operatorText}`;
					div += `<div class="box">
								<div class="operate">${text}</div>
								<div class="values" class="text-truncate">${content}</div>
							</div>
							`;
				});

				div += '</div>'
			}

			return div || '--';
		}
	});

	exports.base = Base;
});